<?php
/**
 * Creates the package.xml file.
 * 
 * PHP version 5
 * 
 * @category Logging
 * @package  Log
 * @author   Michael "Vladimyr" Gower <MichaelPeterGower@gmail.com>
 * @license  http://www.apache.org/licenses/LICENSE-2.0  Apache License 2.0
 * @link     http://pear.php.net/pepr/pepr-proposal-show.php?id=487
 */
 
/**
 * Require the PackageFileManager2 class.
 */
require_once 'PEAR/PackageFileManager2.php';

Log_XML_PackageManagement_main();
echo "Done";
/**
  Creates the package.xml output.  Copy and paste to package.xml.
  Add the following to the xml output under package/dependencies/required.  
  detectDependencies() not finding all dependencies so it has to be done manually.
  To install the package file manager enter "pear install PEAR_PackageFileManager"
  at the command line.
  Auto Detected Dependencies: php 5.2, pear installer 1.5.1
  Other Dependencies: extension pcre, Log 1.9, XML_Beautifier 1.1
  Development Packages: PHP_CodeSniffer, PHP_CompatInfo, PEAR_PackageFileManager, 
	PHPUnit, PhpDocumentor
   <package>
    <name>Log</name>
    <channel>pear.php.net</channel>
    <min>1.9</min>
   </package>
   <package>
    <name>XML_Beautifier</name>
    <channel>pear.php.net</channel>
    <min>1.1</min>
   </package>
   <extension>
    <name>pcre</name>
   </extension>

	@return void No return.
 */
function Log_XML_PackageManagement_main()
{
    PEAR::setErrorHandling(PEAR_ERROR_DIE);
    $packagexml = new PEAR_PackageFileManager2();
    
    // for an existing package.xml use
    // $packagexml = importOptions() instead
    $packagexml->importOptions("../package.xml");
    $e = $packagexml->setOptions(array('baseinstalldir' => '/',
        'packagedirectory' => '..',
        'simpleoutput' => true,
        'ignore' => array('TODO', 'build.xml', 'docs/phpDoc/', 'lib/',
            'xsltransfomer.usersettings', 'compatInfo.php',
            'packageManagement.php', 'log_xml.xml', 'Log_XML-0.4.0.tgz',
            'simpleLog.xml', 'cycle.sh', 'generateDocs.sh', 'cycle.bat',
            'Log-XML.iml', 'testall.sh', 'externalEntitiesMessages.xml',
            'externalEntitiesRoot.xml', 'externalEntitiesTest.php'),
        'roles' => array('xml' => 'data', 'xsd' => 'data', 'php' => 'php'),
        'dir_roles' => array('docs' => 'doc', 'tests' => 'test')));

    $packagexml->setPackage('Log_XML');
    $packagexml->setSummary('A driver for XML output for the Log package.');
    $packagexml->setDescription('Log_XML provides an ability to log to ' .
           'an XML file.  It has an abstract base class and subclasses ' .
           'implement it concretely.  It is extensible to allow for ' .
           'various Schema, no DTD support is planned.');
    $packagexml->setChannel('pear.php.net');
    $packagexml->setAPIVersion('0.4.0');
    $packagexml->setReleaseVersion('0.4.0');
    $packagexml->setReleaseStability('beta');
    $packagexml->setAPIStability('beta');
    $packagexml->setNotes("Initial Release.");
    $packagexml->setPackageType('php');
    $packagexml->addRelease(); // set up a release section

    $packagexml->detectDependencies();

    $packagexml->addRelease(); // add another release section for all other OSes

    $packagexml->setPhpDep('5.2.0');
    $packagexml->setPearinstallerDep('1.5.1');
    $packagexml->addMaintainer('lead', 'designatevoid',
                               'Michael Peter "Vladimyr" Gower',
                               'designatevoid@gmail.com');
    $packagexml->setLicense('Apache 2.0 License',
                            'http://www.apache.org/licenses/LICENSE-2.0');
    $packagexml->generateContents(); // create the <contents> tag

    if (isset($_GET['make'])
        || (isset($_SERVER['argv'])
            && @$_SERVER['argv'][1] == 'make')) {
        $packagexml->writePackageFile();
    } else {
        $packagexml->debugPackageFile();
    }
}